<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'title' => 'GravityCalculator.java',
	'subtitle' => 'Written in <span title="Programming 1">CS 1102</span> of <a href="http://www.uopeople.edu/">University of the People</a>, finalised on 2017-04-12',
	'copyright year' => '2017',
	'body' => <<<END
<h2>Source code:</h2>
<blockquote>
<pre><code>/*
 * Copyright (C) 2017 Alex Yst
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 */
package gravitycalculator;

import java.io.*;

/**
 *
 * @author Alex Yst
 */
public class GravityCalculator {

	public static void main(String[] arguments) {

		double gravity =-9.81; // Earth&apos;s gravity in m/s^2

		double initialVelocity = 0.0; // starting velocity of the object

		double fallingTime = 10.0; // time in seconds that the object falls

		double initialPosition = 1000.0; // Starting position in meters, the calculation will 		determine the ending position in meters
/*
In this equasion, we multiply by fallingTime twice. Why? Because we need to
square it. Java lacks an operator for exponentiation, and calling a function to
do it seems like overkill.
...

For the record though, if we wanted to use the function to do this, Math.pow()
would be a good candidate.
*/
		double finalPosition = 0.5*gravity*fallingTime*fallingTime+initialVelocity*fallingTime+initialPosition;

		System.out.println(&quot;The object&apos;s position after &quot; + fallingTime +&quot; seconds is 			&quot;+finalPosition + &quot; m.&quot;);

	}
}</code></pre>
</blockquote>
<h2>Output:</h2>
<blockquote>
<pre>run:
The object&apos;s position after 10.0 seconds is 			509.49999999999994 m.
BUILD SUCCESSFUL (total time: 1 second)</pre>
</blockquote>
END
);
